/**
 * @author chili
 * @date 2019-05-22
 * @description:弹出组件
 */

// 弹窗容器
function creatNewPopup(html, openBack) {
    common.loading(1)
    if (html) {
        let newPopup = app.popup.create({
            content: html,
            on: {
                opened: function (popup) {
                    if (openBack) {
                        openBack();
                    }
                    common.loading(0)
                },
            }
        });
        newPopup.open();
        //设置容器高度
        jQuery(".rdsp-selectOption").css("height", (newPopup.el.clientHeight - 25) + "px");
    } else {
        app.methods.showToastCenter("未找到弹窗容器");
        common.loading(0)
    }
}

// 联网单位选择--公共页面
var orgRecords = [];
function loadSelectUnitFunc(callback, value) {
    if (!getClickEnabel()) return
    var orgHtml = "";
    var orgRecordHtml = "";
    jQuery("#org_sort_list").empty();
    if (localStorage.getItem("rdsp_search_records")) {
        jQuery(".rdsp-org-popup-top").show();
        orgRecords = JSON.parse(localStorage.getItem("rdsp_search_records"));
    } else {
        jQuery(".rdsp-org-popup-top").hide();
    }

    // 列表
    if (currentUserUnitListData.length > 0) {
        for (var i = 0; i < currentUserUnitListData.length; i++) {
            orgHtml += `<div class="sort_list each-org-list rdsp-sort-list-` + currentUserUnitListData[i].organizationId + `" data-type="1" data-id="` + currentUserUnitListData[i].organizationId + `" data-address="` + currentUserUnitListData[i].address + `">
                    <div class="num_name">`+ common.transNullundefined(currentUserUnitListData[i].shortName) + `</div>
                </div>`;
        }
    }
    if (orgRecords.length > 0) {
        for (var i = 0; i < orgRecords.length; i++) {
            if (orgRecords[i].orgId.indexOf(platformCode + "_" + userInfor.id) >= 0 && currentUserUnitListData.filter(o => o.shortName == orgRecords[i].orgName).length > 0) {
                orgRecordHtml += `<div class="chip each-org-list rdsp-chip-` + orgRecords[i].orgId.split('_')[2] + `" data-type="0"  data-id="` + orgRecords[i].orgId.split('_')[2] + `" data-address="` + orgRecords[i].orgName + `">
                  <div class="chip-label">`+ common.transNullundefined(orgRecords[i].orgName) + `</div>
                </div>`;
            }
        }
    }
    let html = `
    <div class="popup org-popup">
        <div class="rdsp-org-popup">
            <div class="rdsp-org-popup-top">
                <span style="font-size:16px;color: #000;">最近访问单位</span>
                <div class="rdsp-org-list-tags" id="orgRecord_list">`+ orgRecordHtml + `</div>
            </div>
            <div class="rdsp-org-popup-bottom">
                <span class="bind-all-unit" style="font-size:16px;color: #000;">全部单位</span>
                <div class="rdsp-org-list rdsp-org-list-height list">
                    <div class="sort_box" id="org_sort_list" >`+ orgHtml + `</div>
                    <div id="letter"></div>
                </div>
            </div>
            <div class="initials"><ul></ul></div>
        </div>
    </div>`;

    creatNewPopup(html, function () {
        stratSort();

        jQuery(".each-org-list").off().click((event) => {
            var type = jQuery(event.currentTarget).attr("data-type");
            var orgId = jQuery(event.currentTarget).attr("data-id");
            var address = jQuery(event.currentTarget).attr("data-address");
            var orgName = searchUnitNameById[orgId].shortName;
            var orgKey = platformCode + "_" + userInfor.id + "_" + orgId;
            if (callback) {
                callback({
                    "orgId": orgId,
                    "orgName": orgName,
                    "type": type,
                    "longitude": searchUnitNameById[orgId].longitude,
                    "latitude": searchUnitNameById[orgId].latitude,
                    "radius": searchUnitNameById[orgId].radius ? searchUnitNameById[orgId].radius : 200,
                    "address": address,
                });
            }
            // 用户记录存入
            if (!orgRecords.find((n) => n.orgId == orgKey)) {
                if (orgRecords.map((n) => n.orgId.indexOf(platformCode + "_" + userInfor.id) >= 0).length <= 5) {
                    orgRecords.unshift({ "orgId": orgKey, "orgName": orgName });
                } else {
                    orgRecords.pop();
                    orgRecords.unshift({ "orgId": orgKey, "orgName": orgName });
                }
                localStorage.setItem("rdsp_search_records", JSON.stringify(orgRecords));
            }
            app.popup.close();
        });
        // 选中
        $(".each-org-list").removeClass("active").css({
            "background-color": "",
            "color": "rgba(0,0,0,.87)"
        });
        if (value) {
            $(".rdsp-chip-" + value).css({
                "background-color": "#4e9bff",
                "color": "#fff"
            });
        }
        //设置高度
        $('.rdsp-org-list-height').css('height', ($('.org-popup').height() - $('.rdsp-org-popup-top').height() - 75) + 'px')
        // 重新计算导航li高度
        // jQuery('.rdsp-org-popup .initials').css('height', (screen.height - 250) + "px")
        // jQuery('.rdsp-org-popup .initials li').css('height', ((screen.height - 250) / 28) + "px")
    });
}

/* 设备类别选择--公共页面 */
//设备类别
var currentFcsListData = [];
var searchSystemNameById = [];
var searchCategoryNameById = [];
function getDectData(orgId) {
    var pram = {
        userName: userInfor.accountName,
        deviceId: appKeyObj.deviceId,
        orgIds: orgId,
    };
    if (userInfor.role[0].id == 143) {
        var fcFacilitiesCategoryIdArr = [];
        var fcFacilitiesCategoryId = "";
        Dao.selectVenuesRelateInfo_ajax({
            userName: userInfor.accountName,
            deviceId: appKeyObj.deviceId,
            venuesId: nineCode,
            relateObjType: 1
        }, function (data) {
            if (data && data.fcfsList.length > 0) {
                for (var i = 0; i < data.fcfsList.length; i++) {
                    fcFacilitiesCategoryIdArr.push(data.fcfsList[i].fcFacilitiesCategoryId);
                }
                fcFacilitiesCategoryId = fcFacilitiesCategoryIdArr.toString();
            }
        }, false);
        pram = {
            userName: userInfor.accountName,
            deviceId: appKeyObj.deviceId,
            orgIds: orgId,
            categoryIds: fcFacilitiesCategoryId
        };
    }
    Dao.getFcsCategoryList(pram, function (data) {
        if (data && data.length > 0) {
            currentFcsListData = data;
            jQuery.each(data, function (index, el) {
                searchSystemNameById[el.fireSystemId] = { "dectorId": el.fireSystemId, "dectorName": el.fireSystemName };
                jQuery.each(el.fireCtlFacsCategoryList, function (index, el) {
                    searchCategoryNameById[el.id] = { "dectorId": el.id, "dectorName": el.name };
                });
            });
        }
    }, false);
}

function loadSelectDectorFunc(orgId, callback, isHome, value, eltype, dataType) {
    if (!getClickEnabel()) return
    getDectData(orgId);
    var dectorHtml = "";
    var dectorRecordHtml = "";
    var showType = 0;
    var typeTotal = 0;
    if (localStorage.getItem("rdsp_search_records")) {
        jQuery(".rdsp-dector-popup-top").show();
        dectorRecords = JSON.parse(localStorage.getItem("rdsp_search_records"));
    } else {
        jQuery(".rdsp-dector-popup-top").hide();
    }
    jQuery("#dector_sort_list").empty();
    // 列表
    if (currentFcsListData.length > 0) {
        for (var i = 0; i < currentFcsListData.length; i++) {
            // 全部系统类别
            // 系统下的子类别
            if (currentFcsListData[i].fireCtlFacsCategoryList.length > 0) {
                typeTotal = typeTotal + 1;
                dectorHtml += `<div class="sb_sort_list">
                                    <div class="sort_list  each-dector-list rdsp-sort-list-`+ currentFcsListData[i].fireSystemId + `" style="height:35px;"  data-num="` + typeTotal + `" data-type="1" data-id="` + currentFcsListData[i].fireSystemId + `">
                                        <div class="num_name">`+ common.transNullundefined(currentFcsListData[i].fireSystemName) + `</div>
                                    </div>
                                </div>`;
                var facsData = currentFcsListData[i].fireCtlFacsCategoryList;
                for (var j = 0; j < facsData.length; j++) {
                    typeTotal = typeTotal + 1;
                    if (j == 0) {
                        dectorHtml += `<div  class="fcsType` + currentFcsListData[i].fireSystemId + `">`
                    }
                    dectorHtml += `<div style="margin-left: 20px;height:35px;" class="sort_list each-dector-list rdsp-sort-list-category-` + facsData[j].id + `" data-num="` + typeTotal + `" data-type="2" data-id="` + facsData[j].id + `" data-sid="`+currentFcsListData[i].fireSystemId+`">
                                    <div class="num_name" style="color: #333;">`+ common.transNullundefined(facsData[j].name) + `</div>
                                    </div>`;
                    if (j == facsData.length - 1) {
                        dectorHtml += `</div>`;
                    }
                }
            } else {
                typeTotal = typeTotal + 1;
                dectorHtml += `<div class="sort_list each-dector-list rdsp-sort-list-` + currentFcsListData[i].fireSystemId + `" style="height:40px;" data-type="1" data-num="` + typeTotal + `" data-id="` + currentFcsListData[i].fireSystemId + `">
                                <div class="num_name">`+ common.transNullundefined(currentFcsListData[i].fireSystemName) + `</div>
                                </div>`;
            }
        }
    }
    let html = `
        <div class="popup dector-popup">
            <div class="rdsp-dector-popup">
                <div class="rdsp-dector-popup-bottom">
                    <span class="bind-all-unit" style="font-size:18px;">全部消防设备类别</span>
                    <br/>
                    <div class="rdsp-dector-list rdsp-dector-list-height list">
                        <div class="sort_box" id="dector_sort_list" >`+ dectorHtml + `</div>
                        <div id="letter"></div>
                    </div>
                </div>
                <div class="initials"><ul><li></li></ul></div>
        </div>
    </div>`;

    creatNewPopup(html, function () {
        // stratSort();
        jQuery(".iconfont").off().click((event) => {
            var type = jQuery(event.currentTarget).attr("data-id");
            if (showType == 0) {
                $('.fcsType' + type).show();
                showType = 1;
            } else {
                $('.fcsType' + type).hide();
                showType = 0;
            }

        });
        jQuery(".each-dector-list").off().click((event) => {
            var type = jQuery(event.currentTarget).attr("data-type");
            var dectorId = jQuery(event.currentTarget).attr("data-id");
            var sid = jQuery(event.currentTarget).attr("data-sid");
            var dectorName = null;
            if (type == 1) {
                dectorName = searchSystemNameById[dectorId].dectorName;
            } else {
                dectorName = searchCategoryNameById[dectorId].dectorName;
            }

            if (callback) {
                callback({ "dectorId": dectorId, "dectorName": dectorName, "type": type,sid:sid });
            }
            app.popup.close();
        });
        // 选中
        $(".each-dector-list").removeClass("active").css({
            "background-color": "",
            "color": "rgba(0,0,0,.87)"
        });
        if (value) {
            var num_type = 0;
            if (dataType == 1) {
                $(".rdsp-sort-list-" + value).addClass('active');
                num_type = jQuery(".rdsp-sort-list-" + value).attr("data-num");
            } else {
                $(".rdsp-sort-list-category-" + value).addClass('active');
                num_type = jQuery(".rdsp-sort-list-category-" + value).attr("data-num");
            }
            $(".rdsp-dector-list").scrollTop(parseInt(40 * num_type) - 150);
        }
        $('.popup.dector-popup').css('overflow-y','auto')
    });
}

// 筛选条件弹出
function selectOptionFn(list, callback, value, flag) {
    if (!getClickEnabel()) return
    var html = "";
    var listHtml = "";
    var flag = flag;
    if (list.length > 0) {
        for (var i = 0; i < list.length; i++) {
            if (i == list.length - 1) {
                listHtml += `<div class="rdsp-option-list" index-id=` + i + ` id="lastOptionId_` + list[i].id + `" data-id="` + list[i].id + `" data-text = "` + list[i].name + `">` + common.transNullundefined(list[i].name) + `</div>`;
            } else {
                listHtml += `<div class="rdsp-option-list rdsp-option-list-border" index-id=` + i + ` id="lastOptionId_` + list[i].id + `" data-id="` + list[i].id + `" data-text = "` + list[i].name + `">` + common.transNullundefined(list[i].name) + `</div>`;
            }
        }
        html = `
        	<div class="popup selectOptionFn-popup">
        		<div class="rdsp-selectOption">`+ listHtml + `</div>
        	</div>`;

        creatNewPopup(html, function () {
            //隐患整改模块新加
            if (flag) {
                let arr = jQuery(".rdsp-option-list");
                for (let i = 0; i < arr.length; i++) {
                    if (jQuery(arr[i]).html() == "消防设施") {
                        jQuery(arr[i]).append("<span style='font-size: 12px;background-color: #f7b510;color: #fff;padding: 1px;border-radius: 3px; margin-left: 5px;'>故障维修</span>");
                    }
                }
            }
            jQuery(".rdsp-option-list").off().click(function (event) {
                let index = jQuery(event.currentTarget).attr("index-id");
                let id = jQuery(event.currentTarget).attr("data-id");
                let name = jQuery(event.currentTarget).attr("data-text");
                if (callback) {
                    callback({ "id": id, "name": name, "index": index });
                    app.popup.close();
                }
            });
            // 选中
            $(".rdsp-option-list").removeClass("active");
            if (value) {
                $(".rdsp-selectOption").scrollTop(parseInt(40 * value));
                $(".rdsp-option-list").eq(value).addClass('active');
            }
        });
    }
}

//责任人数据请求
function getFourTypeUser(orgId, callback, index, type, isMultipte) {
    if (!getClickEnabel()) return
    common.loading(1);
    let allUserObj = [];
    //单位用户
    Dao.getHaveOrgUserListNotInRole({
        orgIds: orgId,
        roleIds: singleUserId.toString(),
    }, function (data) {
        if (data != null && data.length != 0) {
            for (var i = 0; i < data.length > 0; i++) {
                var obj = {};
                obj.id = data[i].accountName;
                obj.name = data[i].name;
                obj.postName = data[i].postName ? data[i].postName : '';
                obj.type = 'danweiyonghu';
                allUserObj.push(obj);
            }
        }
        //九小用户
        Dao.getHaveOrgUserListNotInRole({
            orgIds: orgId,
            roleIds: nineUserId.toString(),
        }, function (data) {
            if (data != null && data.length != 0) {
                for (var i = 0; i < data.length > 0; i++) {
                    var obj = {};
                    obj.id = data[i].accountName;
                    obj.name = data[i].name;
                    obj.postName = data[i].postName ? data[i].postName : '';
                    obj.type = 'jiuxiaochangsuoyonghu';
                    allUserObj.push(obj);
                }
            }
            //维保公司（小微用户）
            Dao.getHaveOrgUserListNotInRole({
                orgIds: orgId,
                roleIds: maitenceUserId.toString(),
            }, function (data) {
                if (data != null && data.length != 0) {
                    for (var i = 0; i < data.length > 0; i++) {
                        var obj = {};
                        obj.id = data[i].accountName;
                        obj.name = data[i].name;
                        obj.postName = data[i].postName ? data[i].postName : '';
                        obj.type = 'weibaogongsi';
                        allUserObj.push(obj);
                    }
                }
                //其他用户
                Dao.getHaveOrgUserListNotInRole({
                    orgIds: orgId,
                    roleIds: moreUserId.toString(),
                }, function (data) {
                    if (data != null && data.length != 0) {
                        for (var i = 0; i < data.length > 0; i++) {
                            var obj = {};
                            obj.id = data[i].accountName;
                            obj.name = data[i].name;
                            obj.postName = data[i].postName ? data[i].postName : '';
                            obj.type = 'qitayonghu';
                            allUserObj.push(obj);
                        }
                    }
                    loadSelectDutyAndNine(allUserObj, callback, index, type, isMultipte);
                    common.loading(0);
                })

            })

        });

    })

}
// 责任人弹框-公共页面
function loadSelectDutyAndNine(unitPeople, callback, index, type, isMultipte) {

    let html = `
         <div class="popup nine-duty-people-popup">
            <div class="duty-bottom">
                <span class="left multipte-close">取消</span>
                <span class="right multipte-quit">确定</span>
            </div> 
           <div class="toolbar tabbar nine-duty-people" style="height:30px;background: transparent;">
             <div class="toolbar-inner" style="background-color: #FFF;">
                 <a href="#tab-1" class="tab-link tab-link-active">单位用户</a>
                 <a href="#tab-2" class="tab-link" id="selectDutyAndNine-tab-1">小微用户</a>
                 <a href="#tab-4" class="tab-link" id="selectDutyAndNine-tab-3">维保公司</a>
                 <a href="#tab-3" class="tab-link" id="selectDutyAndNine-tab-2">其他用户</a>
             </div>
           </div>
           <div class="tabs" style="overflow: auto;-webkit-overflow-scrolling: touch;overflow-y: scroll;overflow-y: scroll;">
             <div class="tab tab-active" id="tab-1"></div>
             <div class="tab" id="tab-2"></div>
             <div class="tab" id="tab-4"></div>
             <div class="tab" id="tab-3"></div> 
           </div>
       </div>
    `;

    creatNewPopup(html, function () {
        // 单位用户
        var html1 = "";
        var html2 = "";
        var html3 = "";
        var html4 = "";

        // 没有维保公司
        if (JSON.stringify(unitPeople).indexOf("weibaogongsi") < 0) {
            jQuery("#tab-4,#selectDutyAndNine-tab-3").hide();
        }

        for (var i = 0; i < unitPeople.length; i++) {
            if (unitPeople[i].type == 'danweiyonghu') {
                html1 += `<div class="rdsp-option-list rdsp-option-list-border" id="` + unitPeople[i].id + `" style="margin-left:10px;"
                    data-text = "`+ common.transNullundefined(unitPeople[i].name) + `" data-type="1">
                    <label class="checkbox" id="multipte_`+ unitPeople[i].id + `">
                        <input type="checkbox" data-id="`+ unitPeople[i].id + `">
                        <i class="icon-checkbox"></i>
                    </label>
                    `+ (common.transNullundefined(unitPeople[i].name) + (unitPeople[i].postName ? (' - ' + unitPeople[i].postName) : '')) + `
                 </div>`;
            }
            if (unitPeople[i].type == 'jiuxiaochangsuoyonghu') {
                showFlag2 = true;
                html2 += `<div class="rdsp-option-list rdsp-option-list-border" id="` + unitPeople[i].id + `" style="margin-left:10px;"
                    data-text = "`+ common.transNullundefined(unitPeople[i].name) + `" data-type="2">
                    <label class="checkbox" id="multipte_`+ unitPeople[i].id + `">
                        <input type="checkbox" data-id="`+ unitPeople[i].id + `">
                        <i class="icon-checkbox"></i>
                    </label>
                    `+ (common.transNullundefined(unitPeople[i].name) + (unitPeople[i].postName ? (' - ' + unitPeople[i].postName) : '')) + `
                 </div>`;
            }
            if (unitPeople[i].type == 'qitayonghu') {
                showFlag3 = true;
                html3 += `<div class="rdsp-option-list rdsp-option-list-border" id="` + unitPeople[i].id + `" style="margin-left:10px;"
                    data-text = "`+ common.transNullundefined(unitPeople[i].name) + `" data-type="3">
                    <label class="checkbox" id="multipte_`+ unitPeople[i].id + `">
                        <input type="checkbox" data-id="`+ unitPeople[i].id + `">
                        <i class="icon-checkbox"></i>
                    </label>
                    `+ (common.transNullundefined(unitPeople[i].name) + (unitPeople[i].postName ? (' - ' + unitPeople[i].postName) : '')) + `
                 </div>`;
            }
            if (unitPeople[i].type == 'weibaogongsi') {
                showFlag4 = true;
                html4 += `<div class="rdsp-option-list rdsp-option-list-border" id="` + unitPeople[i].id + `" style="margin-left:10px;"
                    data-text = "`+ common.transNullundefined(unitPeople[i].name) + `" data-type="4">
                    <label class="checkbox" id="multipte_`+ unitPeople[i].id + `">
                        <input type="checkbox" data-id="`+ unitPeople[i].id + `">
                        <i class="icon-checkbox"></i>
                    </label>
                    `+ (common.transNullundefined(unitPeople[i].name) + (unitPeople[i].postName ? (' - ' + unitPeople[i].postName) : '')) + `
                 </div>`;
            }
        }
        //  if(app.view.current.el.f7View.router.currentPageEl.f7Component.pageName=='changeShiftsDetails'){
        //     jQuery('.nine-duty-people-popup').eq(0).show().siblings('.nine-duty-people-popup').hide()
        // }
        $("#tab-1").html(`<div class="rdsp-selectOption" style="height: 100%;overflow: auto;" >` + html1 + `</div>`);
        // 九小场所用户
        $("#tab-2").html(`<div class="rdsp-selectOption" style="height: 100%;overflow: auto;">` + html2 + `</div>`);
        // 其他用户
        $("#tab-3").html(`<div class="rdsp-selectOption" style="height: 100%;overflow: auto;">` + html3 + `</div>`);
        $("#tab-4").html(`<div class="rdsp-selectOption" style="height: 100%;overflow: auto;">` + html4 + `</div>`);

        //多选展示确定按钮
        if (isMultipte) {
            jQuery(".rdsp-option-list .checkbox").show();
            jQuery(".nine-duty-people").css("border-top", "1px solid #eee");
            jQuery(".rdsp-option-list .checkbox input[type=checkbox]").prop("checked", false);
            jQuery(".duty-bottom").show();
            jQuery(".multipte-close").off().click(function () {
                if (app.view.current.el.f7View.router.currentPageEl.f7Component.pageName == 'changeShiftsDetails') {
                    jQuery('.nine-duty-people-popup').remove()
                } else {
                    app.popup.close();
                }
            });
            jQuery(".multipte-quit").off().click(function () {
                let names = [];
                let types = [];
                let cIds = [];
                let allCkeckArr = jQuery(".rdsp-option-list .checkbox input[type=checkbox]:checked");
                jQuery.each(allCkeckArr, function (index, item) {
                    let name = jQuery(item).parent().parent().attr("data-text");
                    let type = jQuery(item).parent().parent().attr("data-type")
                    let cId = jQuery(item).attr("data-id");
                    names.push(name);
                    types.push(type * 1);
                    cIds.push(cId);
                });
                callback({
                    "id": cIds.toString(),
                    "name": names.toString(),
                    "type": types.toString(),
                    "index": cIds.toString()
                });
                // if (app.view.current.el.f7View.router.currentPageEl.f7Component.pageName == 'changeShiftsDetails') {
                //     jQuery('.nine-duty-people-popup').remove()
                // } else {
                app.popup.close();
                // }
            })
        } else {
            jQuery(".rdsp-option-list .checkbox").hide();
            jQuery(".nine-duty-people").css("border-top", "");
            jQuery(".duty-bottom").hide();
        }

        if (!isMultipte) {
            jQuery(".rdsp-option-list").off().click(function (event) {
                let id = jQuery(event.currentTarget).attr("id");
                let name = jQuery(event.currentTarget).attr("data-text");
                let type = jQuery(event.currentTarget).attr("data-type");
                if (callback) {
                    callback({
                        "id": id,
                        "name": name,
                        "type": type * 1,
                        "index": id
                    });
                    app.popup.close();
                }
            });
        }
        // 选中
        if (type) {
            if (type.toString().split(",").length > 0) {
                type = type.toString().split(",")[type.toString().split(",").length - 1];
            }
            app.tab.show("#tab-" + type);
        } else {
            app.tab.show("#tab-1");
        }
        $(".rdsp-option-list").removeClass("active");
        if (index) {
            if (!isMultipte) {
                $("#tab-" + type + " #" + index).addClass('active');
            } else {
                let indexArr = index.split(",");
                for (let n = 0; n < indexArr.length; n++) {
                    jQuery("#multipte_" + indexArr[n] + " input[type=checkbox]").prop("checked", true);
                }
            }
        }

        //设置高度
        let allHeight = jQuery(".nine-duty-people-popup").height();
        jQuery(".nine-duty-people-popup .tabs").css("height", (allHeight - 50) + "px");
    });

}

// 时间选择
/*******************************************************************************
 * type 1、年月日时分 2. 年 4.年月 3、月日
 */
function loadSelectedDate_Fn(type, callback, oldDate) {
    if (!getClickEnabel()) return
    let html = `<div class="popup data-popup">
	          <div class="select-date-top">
	            <span class="left">选择日期</span>
	            <span class="right" id="confirmDate">确定</span>
	          </div>
	          <div class="select-date-div">
	            <input class="select-date-input" id="selectDate"/>
	          </div> 
	          <div id="date-select-list"></div>
	        </div>`;

    /*
     * if (type == 3 || type == 4) { html = `<div class="popup data-popup"> <div
     * class="select-date-top"> <span class="left">选择日期</span> <span class="right"
     * id="confirmDate">确定</span> </div> <div class="select-date-div"> <div
     * class="left-div active-div"> <span>开始</span> <label></label> <input
     * type="hidden" class="select-date-input" id="startDate"/> </div> <div
     * class="right-div"> <span>结束</span> <label></label> <input type="hidden"
     * class="select-date-input" id="endDate"/> </div> </div> <div
     * id="date-select-list"></div> </div>`; }
     */

    creatNewPopup(html, function () {
        if (type == 1) {
            singleDate("selectDate", oldDate);
        } else if (type == 3) {
            monthDay("selectDate");
        } else if (type == 4) {
            yearMonth("selectDate", oldDate);
        } else if (type == 5) {
            singYearMonthDay("selectDate");
        }

        // 提交时间
        jQuery("#confirmDate").off().click(function () {
            if (callback) {
                var singleDate = jQuery("#selectDate").val();
                var startDate = "";
                var endDate = "";
                if (type == 1) {
                    callback({
                        "singleDate": singleDate + ":00",
                    });
                } else if (type == 3) {
                    var year = moment().format("YYYY-MM-DD").substring(0, 4);
                    startDate = year + '-' + singleDate + " 00:00:00";
                    endDate = year + '-' + singleDate + " 23:59:59";
                    callback({
                        "startTime": startDate,
                        "endTime": endDate,
                    });
                } else if (type == 4) {
                    var year = parseInt(singleDate.substring(0, 4));
                    var month = parseInt(singleDate.substring(5, singleDate.length));
                    var MonthDay = [];
                    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                        MonthDay = ['0', '31', '29', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31'];
                        startDate = singleDate + "-01 00:00:00";
                        endDate = singleDate + '-' + MonthDay[month] + " 23:59:59";
                    } else {
                        MonthDay = ['0', '31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31'];
                        startDate = singleDate + "-01 00:00:00";
                        endDate = singleDate + '-' + MonthDay[month] + " 23:59:59";
                    }
                    callback({
                        "startTime": startDate,
                        "endTime": endDate,
                    });
                } else if (type == 5) {

                    callback({
                        "singleDate": singleDate,
                    });


                }
                // if (app.view.current.el.f7View.router.currentPageEl.f7Component.pageName == 'changeShiftsDetails') {
                //     jQuery('.data-popup').remove()
                // } else {
                app.popup.close();
                // }
            }
        });
    });
}

// 时间选择器 - 年月日时分秒
function singleDate(idName, oldDate) {
    var today = new Date();
    let dateValArr;
    if (app.view.current.el.f7View.router.currentPageEl.f7Component.pageName = 'creteShifts' || app.view.current.el.f7View.router.currentPageEl.f7Component.pageName == 'changeShiftsDetails') {
        if (oldDate == '' || !oldDate || oldDate == '选择开始时间' || oldDate == '选择结束时间') {
            dateValArr = [
                today.getFullYear() + "年",
                today.getMonth(),
                today.getDate() + "日",
                today.getHours() + "时",
                today.getMinutes() < 10 ? '0' + today.getMinutes() + '分' : today.getMinutes() + '分'
            ]
        } else {
            dateValArr = [new Date(oldDate.replace(/\-/g, "/")).getFullYear() + '年', new Date(oldDate.replace(/\-/g, "/")).getMonth(),
            new Date(oldDate.replace(/\-/g, "/")).getDate() + '日', new Date(oldDate.replace(/\-/g, "/")).getHours() + '时', new Date(oldDate.replace(/\-/g, "/")).getMinutes() < 10 ? '0' + new Date(oldDate.replace(/\-/g, "/")).getMinutes() + '分' : new Date(oldDate.replace(/\-/g, "/")).getMinutes() + '分']
        }
    } else {
        dateValArr = [
            today.getFullYear() + "年",
            today.getMonth(),
            today.getDate() + "日",
            today.getHours() + "时",
            today.getMinutes() < 10 ? '0' + today.getMinutes() + '分' : today.getMinutes() + '分'
        ]
    }
    var pickerInline = app.picker.create({
        containerEl: '#date-select-list',
        inputEl: '#' + idName,
        toolbar: false,
        rotateEffect: false,
        value: dateValArr,
        formatValue: function (values, displayValues) {
            var year = displayValues[0].substring(0, displayValues[0].length - 1);
            var month = displayValues[1].substring(0, displayValues[1].length - 1);
            month = parseInt(month) < 10 ? '0' + month : month;
            var day = values[2].substring(0, values[2].length - 1);
            day = parseInt(day) < 10 ? '0' + day : day;
            var hour = values[3].substring(0, values[3].length - 1);
            hour = parseInt(hour) < 10 ? '0' + hour : hour;
            var minute = values[4].substring(0, values[4].length - 1);
            return year + "-" + month + "-" + day + "  " + hour + ":" + minute;
        },
        cols: [
            // Years
            {
                values: (function () {
                    var arr = [];
                    for (var i = 1950; i <= 2030; i++) { arr.push(i + "年"); }
                    return arr;
                })(),
                textAlign: 'left'
            },
            // Months
            {
                values: ('0 1 2 3 4 5 6 7 8 9 10 11').split(' '),
                displayValues: ('1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月').split(' '),
                textAlign: 'left'
            },
            // Days
            {
                // values:
                // [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
                values: (function () {
                    var arr = [];
                    for (var i = 1; i <= 31; i++) { arr.push(i + '日'); }
                    return arr;
                })(),
                textAlign: 'left'
            },
            /*
             * // Space divider { divider: true, content: ' ' },
             */
            // Hours
            {
                values: (function () {
                    var arr = [];
                    for (var i = 0; i <= 23; i++) { arr.push(i + '时'); }
                    return arr;
                })(),
            },
            /*
             * // Divider { divider: true, content: ' ' },
             */
            // Minutes
            {
                values: (function () {
                    var arr = [];
                    for (var i = 0; i <= 59; i++) { arr.push(i < 10 ? '0' + i + '分' : i + '分'); }
                    return arr;
                })(),
            }
        ],
        on: {
            change: function (picker, values, displayValues) {
                var daysInMonth = new Date(picker.value[2], picker.value[0] * 1 + 1, 0).getDate();
                if (values[1] > daysInMonth) {
                    picker.cols[1].setValue(daysInMonth);
                }
                var year = displayValues[0].substring(0, displayValues[0].length - 1);
                var month = displayValues[1].substring(0, displayValues[1].length - 1);
                month = parseInt(month) >= 10 ? month : '0' + month;
                var day = displayValues[2].substring(0, displayValues[2].length - 1);
                day = parseInt(day) >= 10 ? day : '0' + day
                picker.$inputEl.prev().html(year + '-' + month + '-' + day);
            },
        }
    });
}

// 时间选择器 - 年月日
function singYearMonthDay(idName) {
    var today = new Date();
    var pickerInline = app.picker.create({
        containerEl: '#date-select-list',
        inputEl: '#' + idName,
        toolbar: false,
        rotateEffect: false,
        value: [
            today.getFullYear() + '年',
            today.getMonth(),
            today.getDate() + '日',
        ],
        formatValue: function (values, displayValues) {

            var year = displayValues[0].substring(0, displayValues[0].length - 1);
            var month = displayValues[1].substring(0, displayValues[1].length - 1);
            month = parseInt(month) < 10 ? '0' + month : month;
            var day = values[2].substring(0, values[2].length - 1);
            day = parseInt(day) < 10 ? '0' + day : day;
            return year + "-" + month + "-" + day;
        },
        cols: [
            // Years
            {
                values: (function () {
                    var arr = [];
                    for (var i = 1950; i <= 2030; i++) { arr.push(i + "年"); }
                    return arr;
                })(),
                textAlign: 'left'
            },
            // Months
            {
                values: ('0 1 2 3 4 5 6 7 8 9 10 11').split(' '),
                displayValues: ('1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月').split(' '),
                textAlign: 'left'
            },
            // Days
            {
                // values:
                // [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
                values: (function () {
                    var arr = [];
                    for (var i = 1; i <= 31; i++) { arr.push(i + '日'); }
                    return arr;
                })(),
                textAlign: 'left'
            },
        ],
        on: {
            change: function (picker, values, displayValues) {
                var daysInMonth = new Date(picker.value[2], picker.value[0] * 1 + 1, 0).getDate();
                if (values[1] > daysInMonth) {
                    picker.cols[1].setValue(daysInMonth);
                }
                var year = displayValues[0].substring(0, displayValues[0].length - 1);
                var month = displayValues[1].substring(0, displayValues[1].length - 1);
                month = parseInt(month) >= 10 ? month : '0' + month;
                var day = displayValues[2].substring(0, displayValues[2].length - 1);
                day = parseInt(day) >= 10 ? day : '0' + day
                picker.$inputEl.prev().html(year + '-' + month + '-' + day);
            },
        }
    });
}

// 时间选择器 - 年月
function yearMonth(idName, oldDate) {
    var today = new Date();
    var dateValArr = [today.getFullYear() + '年', today.getMonth()];
    if (oldDate) {
        var tempTimeYear = new Date(oldDate.replace(/\-/g, "/")).getFullYear() + '年';
        var tempTimeMonth = new Date(oldDate.replace(/\-/g, "/")).getMonth();
        dateValArr = [tempTimeYear, tempTimeMonth];
    }
    var pickerInline = app.picker.create({
        containerEl: '#date-select-list',
        inputEl: '#' + idName,
        toolbar: false,
        rotateEffect: false,
        value: dateValArr,
        formatValue: function (values, displayValues) {
            var year = displayValues[0].substring(0, displayValues[0].length - 1);
            var month = displayValues[1].substring(0, displayValues[1].length - 1);
            month = parseInt(month) < 10 ? '0' + month : month;
            return year + "-" + month;
        },
        cols: [
            // Years
            {
                values: (function () {
                    var arr = [];
                    for (var i = 1950; i <= 2030; i++) { arr.push(i + "年"); }
                    return arr;
                })(),
                textAlign: 'left'
            },
            // Months
            {
                values: ('0 1 2 3 4 5 6 7 8 9 10 11').split(' '),
                displayValues: ('1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月').split(' '),
                textAlign: 'left'
            },
        ],
        on: {
            change: function (picker, values, displayValues) {
                var daysInMonth = new Date(picker.value[2], picker.value[0] * 1 + 1, 0).getDate();
                if (values[1] > daysInMonth) {
                    picker.cols[1].setValue(daysInMonth);
                }
            },
        }
    });
}

// 时间选择器 - 月日
function monthDay(idName) {
    var today = new Date();
    var pickerInline = app.picker.create({
        containerEl: '#date-select-list',
        inputEl: '#' + idName,
        toolbar: false,
        rotateEffect: false,
        value: [
            today.getMonth(),
            today.getDate() + '日',
        ],
        formatValue: function (values, displayValues) {
            var month = displayValues[0].substring(0, displayValues[0].length - 1);
            month = parseInt(month) < 10 ? '0' + month : month;
            var day = values[1].substring(0, values[1].length - 1);
            day = parseInt(day) < 10 ? '0' + day : day;
            return month + "-" + day;
        },
        cols: [
            // Months
            {
                values: ('0 1 2 3 4 5 6 7 8 9 10 11').split(' '),
                displayValues: ('1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月').split(' '),
                textAlign: 'left'
            },
            // Days
            {
                // values:
                // [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
                values: (function () {
                    var arr = [];
                    for (var i = 1; i <= 31; i++) { arr.push(i + '日'); }
                    return arr;
                })(),
                textAlign: 'left'
            },
        ],
        on: {
            change: function (picker, values, displayValues) {
                var daysInMonth = new Date(picker.value[2], picker.value[0] * 1 + 1, 0).getDate();
                if (values[1] > daysInMonth) {
                    picker.cols[1].setValue(daysInMonth);
                }
            },
        }
    });
}

/**
 * @Author: Chili
 * @Description: 记录page筛选条件
 * @Date: 2019-08-13 09:54:58
 */
function saveSelectOption(option) {
    if (option) {
        localStorage.setItem("ilink_select_option", '');
        localStorage.setItem("ilink_select_option", JSON.stringify(option));
    }
}


/**
 * @author hiny
 * @Description 标签学习弹框-公共页面
 * @param {标签数据} data 
 * @param {回调} callback 
 */
function loadTags(data, selectLable, callback) {
    var tagTypeHtml = '';
    if (data) {
        for (var i = 0; i < data.length; i++) {
            var tagHtml = '';
            var tags = data[i].tags.split(',');
            for (var m in tags) {
                if (jQuery.inArray(tags[m], selectLable) > -1) {
                    tagHtml += "<div class='study-popup-tag active'>" + tags[m] + "</div>";
                } else {
                    tagHtml += "<div class='study-popup-tag'>" + tags[m] + "</div>";
                }
            }
            tagTypeHtml += `
                <div class="study-popup-tagType">
                    <p>`+ data[i].name + `</p>
                    <div class='study-popup-tags'>
                        `+ tagHtml + `
                    </div>
                </div>
            `;
        }
    }
    let html = `
         <div class="popup nine-duty-people-popup" style="height:70%!important">
            <div class="ilink-study-popup-top" style="text-align: center;">
                <span style="font-size:16px;color: #000;">选择文章标签</span>
            </div>
           <div style="overflow: auto;-webkit-overflow-scrolling: touch;overflow-y: scroll;overflow-y: scroll;height: 100%;width: 100%;">
                <div class="types" style="margin-bottom:60px">
                    `+ tagTypeHtml + `
                </div>
           </div>
       </div>
    `;
    creatNewPopup(html, function () {
        callback && callback();
    });
}
//选择消防系统
function loadSelectSystem(orgId, callback, isHome, value, eltype, dataType) {
    if (!getClickEnabel()) return
    getDectData(orgId);
    var dectorHtml = "";
    var showType = 0;
    var typeTotal = 0;
    if (localStorage.getItem("rdsp_search_records")) {
        jQuery(".rdsp-dector-popup-top").show();
        dectorRecords = JSON.parse(localStorage.getItem("rdsp_search_records"));
    } else {
        jQuery(".rdsp-dector-popup-top").hide();
    }
    jQuery("#dector_sort_list").empty();
    // 列表
    if (currentFcsListData.length > 0) {
        for (var i = 0; i < currentFcsListData.length; i++) {
            // 全部系统类别
            // 系统下的子类别
            if (currentFcsListData[i].fireCtlFacsCategoryList.length > 0) {
                typeTotal = typeTotal + 1;
                dectorHtml += `<div class="sb_sort_list">
                                    <div class="sort_list  each-dector-list rdsp-sort-list-`+ currentFcsListData[i].fireSystemId + `" style="height:35px;"  data-num="` + typeTotal + `" data-type="1" data-id="` + currentFcsListData[i].fireSystemId + `">
                                        <div class="num_name">`+ common.transNullundefined(currentFcsListData[i].fireSystemName) + `</div>
                                    </div>
                                </div>`;
            } else {
                typeTotal = typeTotal + 1;
                dectorHtml += `<div class="sort_list each-dector-list rdsp-sort-list-` + currentFcsListData[i].fireSystemId + `" style="height:40px;" data-type="1" data-num="` + typeTotal + `" data-id="` + currentFcsListData[i].fireSystemId + `">
                                <div class="num_name">`+ common.transNullundefined(currentFcsListData[i].fireSystemName) + `</div>
                                </div>`;
            }
        }
    }
    let html = `
    <div class="popup dector-popup">
        <div class="rdsp-dector-popup">
            <div class="rdsp-dector-popup-bottom">
                <span class="bind-all-unit" style="font-size:18px;">全部消防设备类别</span>
                <br/>
                <div class="rdsp-dector-list rdsp-dector-list-height list">
                    <div class="sort_box" id="dector_sort_list" >`+ dectorHtml + `</div>
                    <div id="letter"></div>
                </div>
            </div>
            <div class="initials"><ul><li></li></ul></div>
    </div>
    </div>`;

    creatNewPopup(html, function () {
        // stratSort();
        jQuery(".iconfont").off().click((event) => {
            var type = jQuery(event.currentTarget).attr("data-id");
            if (showType == 0) {
                $('.fcsType' + type).show();
                showType = 1;
            } else {
                $('.fcsType' + type).hide();
                showType = 0;
            }

        });
        jQuery(".each-dector-list").off().click((event) => {
            var type = jQuery(event.currentTarget).attr("data-type");
            var dectorId = jQuery(event.currentTarget).attr("data-id");
            var dectorName = null;
            if (type == 1) {
                dectorName = searchSystemNameById[dectorId].dectorName;
            } else {
                dectorName = searchCategoryNameById[dectorId].dectorName;
            }

            if (callback) {
                callback({ "dectorId": dectorId, "dectorName": dectorName, "type": type });
            }
            app.popup.close();
        });
        // 选中
        $(".each-dector-list").removeClass("active").css({
            "background-color": "",
            "color": "rgba(0,0,0,.87)"
        });
        if (value) {
            var num_type = 0;
            if (dataType == 1) {
                //$(".rdsp-sort-list-"+value).addClass('active'); 
                num_type = jQuery(".rdsp-sort-list-" + value).attr("data-num");
            } else {
                //$(".rdsp-sort-list-category-"+value).addClass('active');
                num_type = jQuery(".rdsp-sort-list-category-" + value).attr("data-num");
            }
            $(".rdsp-dector-list").scrollTop(parseInt(40 * num_type) - 150);
        }
    });
}
//选择屏蔽用户角色
// 责任人弹框-公共页面
function loadSelectPeople(peopleList, idList, callback) {
    var html1 = "";
    for (var i = 0; i < peopleList.length; i++) {
        html1 += `<div class="rdsp-option-list rdsp-option-list-border" id="rdsp-option-list` + peopleList[i].id + `" style="margin-left:10px;"
            data-text = "`+ common.transNullundefined(peopleList[i].name) + `" data-type="1" data-id="` + peopleList[i].id + `" data-name="` + peopleList[i].name + `">
            <label class="checkbox" id="multipte_`+ peopleList[i].id + `">
                <input id="input`+ peopleList[i].id + `" class="checkbox" type="checkbox" data-id="` + peopleList[i].id + `" data-id="` + peopleList[i].id + `" data-name="` + peopleList[i].name + `">
                <i id="i`+ peopleList[i].id + `" class="icon-checkbox" data-id="` + peopleList[i].id + `" data-name="` + peopleList[i].name + `"></i>
            </label>
            `+ (common.transNullundefined(peopleList[i].name)) + `
        </div>`;
    }
    let html = `
         <div class="popup nine-duty-people-popup">
            <div class="duty-bottom">
                <span class="right multipte-quit">确定</span>
            </div> 
           <div class="tabs" style="overflow: auto;-webkit-overflow-scrolling: touch;overflow-y: scroll;overflow-y: scroll;">
             <div class="tab tab-active" id="tab-1">`+ html1 + `</div>
           </div>
       </div>
    `;

    creatNewPopup(html, function () {
        jQuery(".duty-bottom").show();
        let allHeight = jQuery(".nine-duty-people-popup").height();
        jQuery(".nine-duty-people-popup .tabs").css("height", (allHeight - 50) + "px");
        callback && callback();
    });

}

// 离线作业下载
function loadofflineWorkdownload(callback) {
    var html1 = "";
    html1 += `
            <div id="box3"></div>
        `;
    let html = `
         <div class="popup offline-popup-main" styly="height:50% !important">
            <div style="" class="load_down_offline">
                <div class="tab tab-active" id="tab-1">`+ html1 + `</div>
                <div class="load_title_offline">`+ " 请稍后" + `</div>
                <div class="load_content_offline">`+ " 系统正在为您下载作业数据" + `</div>
                <div class="load_cancle_offline">`+ " 取消" + `</div>
            </div>
            <div style="text-align: center;display:none"  class="load_downSuccess_offline">
                <i class="iconfont icon-duigou1 load_success_offline"></i>
                <div class="load_title_offline" style="margin-top:0px">`+ " 下载成功，您可以离线作业了！" + `</div>
                <div class="load_content_offline">`+ " ~记得，及时关闭离线作业哦！" + `</div>
                <div class="start_offlineWork" id="start_offlineWork">`+ " 开始作业" + `</div>
            </div>
            <div style="text-align: center;display:none" class="load_downfail_offline">
                <i class="iconfont icon-cha load_fail_offline"></i>
                <div class="load_title_offline">`+ " 下载数据失败" + `</div>
                <div class="load_content_offline">`+ " 请确保当前网络环境正常后再重新下载" + `</div>
                <div class="start_offlineWork_fail" id="start_offlineWork"><div class="start_offlineWork_cancel">`+ " 取消" + `</div><div class="start_offlineWork_again">` + " 重新下载" + `</div></div>
            </div>
       </div>
    `;

    creatNewPopup(html, function () {
        jQuery(".backdrop-in").append(`<div class="ilink-popup-backdrop ilink-backdrop-in"></div>`);
        jQuery('.ilink-popup-backdrop').on('click', function (e) {
            e.preventDefault();
        })
        jQuery(".duty-bottom").show();
        let allHeight = jQuery(".offline-popup-main").height();
        jQuery(".offline-popup-main .tabs").css("height", (allHeight - 50) + "px");
        callback && callback();
    });
}
// 离线作业上传
function loadofflineWorkupload(callback) {
    var html1 = "";
    html1 += `
        <div id="box3"></div>
    `;
    let html = `
         <div class="popup offline-popup-main">
            <div style="text-align: center;height: 100%;" class="load_add_offline">
                <div class="load_title_offline" style="height: 80%;line-height: 242px;margin-top:0px">`+ " 确定结束离线作业吗？" + `</div>
                <div class="start_offlineWork_fail" id="start_offlineWork"><div class="start_offlineWork_cancel">`+ " 取消" + `</div><div class="start_offlineWork_sure">` + " 确定" + `</div></div>
            </div>
            <div style="display:none" class="load_loading_offline">
                <div class="tab tab-active" id="tab-1">`+ html1 + `</div>
                <div class="load_title_offline load_ing_offline">`+ " 请勿退出" + `</div>
                <div class="load_title_offline load_jieshu_offline" style="display:none">`+ " 上传成功" + `</div>
                <div class="load_content_offline load_ing_offline">`+ " 系统正在为您上传作业数据" + `</div>
                <div class="load_content_offline load_jieshu_offline" style="display:none">`+ "点击确定后退出 " + `</div>
                <div class="load_cancle_offline" style="background:#999">`+ " 正在上传..." + `</div>
                <div class="load_queding_offline" style="display:none">`+ " 确定" + `</div>
            </div>
            <div style="display:none" class="load_none_offline">
                <div class="load_title_offline" style="margin-top: 21%;font-size: 20px;">`+ " 未发现需要提交的作业数据" + `</div>
                <div class="load_queding_offline" style="margin-top: 118px;">`+ " 确定" + `</div>
            </div>
            <div style="text-align: center;display:none" class="load_fails_offline">
                <i class="iconfont icon-cha load_fail_offline"></i>
                <div class="load_title_offline">`+ " 上传数据失败" + `</div>
                <div class="load_content_offline">`+ " 请确保当前网络环境正常后再重新上传" + `</div>
                <div class="start_offlineWork_fail" id="start_offlineWork"><div class="start_offlineWork_cancel">`+ " 取消" + `</div><div class="start_offlineWork_giveUp" style="display:none">` + " 放弃" + `</div><div class="start_offlineWork_again">` + " 重新上传" + `</div></div>
            </div>
       </div>
    `;

    creatNewPopup(html, function () {
        jQuery(".backdrop-in").append(`<div class="ilink-popup-backdrop ilink-backdrop-in"></div>`);
        jQuery('.ilink-popup-backdrop').on('click', function (e) {
            e.preventDefault();
        })
        jQuery(".duty-bottom").show();
        let allHeight = jQuery(".offline-popup-main").height();
        jQuery(".offline-popup-main .tabs").css("height", (allHeight - 50) + "px");
        callback && callback();
    });
}


// 报表分享弹框
function shareBbView(isEmail, callback) {
    let html = ''
    if (isEmail == 'noEmail') {
        html = `
        <div class="popup shareBbmask">
        <div class="shareBbmaskcontent">
            <div class="shareBbmasktitle">请选择分享方式</div>
            <div class="shareBbmaskshare-box">
                <div id="goWxFriends"><img src="${staticPath}img/shareimages/iconmoreOperationshareFriend.png" class="shareBbmaskshare"><div class="share-text">微信</div></div>
                <div id="goWxFriendsMoment"><img src="${staticPath}img/shareimages/iconmoreOperationshareMoment.png" class="shareBbmaskshare"><div class="share-text">朋友圈</div></div>
                <div id="goQQFriends"><img src="${staticPath}img/shareimages/iconmoreOperationshareQQ.png" class="shareBbmaskshare"><div class="share-text">QQ</div></div>
                <div id="goQzone"><img src="${staticPath}img/shareimages/iconmoreOperationshareQzone.png" class="shareBbmaskshare"><div class="share-text">QQ空间</div></div>
                <div id="systemShare"><img src="${staticPath}img/shareimages/iconmoreOperationshareSystem.png" class="shareBbmaskshare"><div class="share-text">系统</div></div>
            </div>
            <div class="shareBbmaskline"></div>
                <div class="shareBbmaskfail-btn" id="closeShareModal">取消</div>
            </div>       
        </div>
        `;
    } else {
        html = `
        <div class="popup shareBbmask">
        <div class="shareBbmaskcontent">
            <div class="shareBbmasktitle">请选择分享方式</div>
            <div class="shareBbmaskshare-box">
                <div id="goWxFriends"><img src="${staticPath}img/shareimages/iconmoreOperationshareFriend.png" class="shareBbmaskshare"><div class="share-text">微信</div></div>
                <div id="goWxFriendsMoment"><img src="${staticPath}img/shareimages/iconmoreOperationshareMoment.png" class="shareBbmaskshare"><div class="share-text">朋友圈</div></div>
                <div id="goQQFriends"><img src="${staticPath}img/shareimages/iconmoreOperationshareQQ.png" class="shareBbmaskshare"><div class="share-text">QQ</div></div>
                <div id="goQzone"><img src="${staticPath}img/shareimages/iconmoreOperationshareQzone.png" class="shareBbmaskshare"><div class="share-text">QQ空间</div></div>
                <div id="goMail"><img src="${staticPath}img/shareimages/iconmoreOperationmail.png" class="shareBbmaskshare"><div class="share-text">邮件</div></div>
                <div id="systemShare"><img src="${staticPath}img/shareimages/iconmoreOperationshareSystem.png" class="shareBbmaskshare"><div class="share-text">系统</div></div>
            </div>
            <div class="shareBbmaskline"></div>
                <div class="shareBbmaskfail-btn" id="closeShareModal">取消</div>
            </div>       
        </div>
        `;
    }

    creatNewPopup(html, function () {
    });
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isIOS = u.indexOf('iPhone') > -1 || u.indexOf('iPad') > -1; //IOS终端
    if(isAndroid){
        jQuery("#systemShare").hide()
    }else if(isIOS){
        jQuery("#goWxFriends").hide()
        jQuery("#goWxFriendsMoment").hide()
        jQuery("#goQQFriends").hide()
        jQuery("#goQzone").hide()
    }
    //微信
    jQuery('#goWxFriends').click(function () {
        callback && callback("WxFriends");
        colsePopup();
    });
    //朋友圈
    jQuery('#goWxFriendsMoment').click(function () {
        callback && callback("WxFriendsMoment");
        colsePopup();
    });
    //QQ
    jQuery('#goQQFriends').click(function () {
        callback && callback("QQFriends");
        colsePopup();
    });
    //QQ空间
    jQuery('#goQzone').click(function () {
        callback && callback("Qzone");
        colsePopup();
    });
    //邮件
    jQuery('#goMail').click(function () {
        colsePopup();
        callback && callback("Mail");
    });
    // 系统分享
    jQuery('#systemShare').click(function () {
        colsePopup();
        callback && callback("systemShare");
    });
    //取消按钮
    jQuery('#closeShareModal').click(function () {
        colsePopup();
    });
    //统一关闭弹框
    function colsePopup() {
        jQuery(".shareBbmask").empty();
        app.popup.close();
    }
}
